//
//  KLNewFeatureController.m
//  WisdomFamilyDoctor
//
//  Created by jinglian on 16/3/25.
//  Copyright © 2016年 kinglian. All rights reserved.
//

#import "GPNewFeatureController.h"

static NSInteger const kImageCount = 5; //  图片数

@interface GPNewFeatureController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
/** 属性 */
@property (nonatomic, strong) UIImageView *imageView;
@end

@implementation GPNewFeatureController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.scrollView.contentSize = CGSizeMake(kScreenWidth * kImageCount, kScreenHeight);
    
    for (int i = 0; i < kImageCount; i++) {
        // 图片不要放在Assets.xcassets文件中
        NSString *imageName = nil;
        imageName = [NSString stringWithFormat:@"%d", i + 1];
        
        
        NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName ofType:@"jpg"];
        
        self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imagePath]];
        self.imageView.frame = CGRectMake(i * kScreenWidth, 0, kScreenWidth, kScreenHeight);
        [self.scrollView addSubview:self.imageView];
        
        if (i == kImageCount - 1) {
            UIButton *enterButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [enterButton setTitle:@"Let’s Start" forState:UIControlStateNormal];
            [enterButton setBackgroundColor: [UIColor blueColor] forState:UIControlStateNormal];
            [enterButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            enterButton.frame = CGRectMake(kScreenWidth/2 - 60, 0.6 * kScreenHeight, 120, 32);
            [enterButton addTarget:self action:@selector(enterButtonClick) forControlEvents:UIControlEventTouchUpInside];
            enterButton.layer.masksToBounds = YES;
            enterButton.layer.cornerRadius = 5.0;
            
            self.imageView.userInteractionEnabled = YES;
            [self.imageView addSubview:enterButton];

        }
    }
}

- (void)enterButtonClick {
    
    if (self.callback) {
        self.callback();
    }
    
}


@end
